package com.example.onlinereadingsystem.demos.web.controller.web;

import com.example.onlinereadingsystem.demos.web.dto.request.LoginParam;
import com.example.onlinereadingsystem.demos.web.dto.request.RegisterParam;
import com.example.onlinereadingsystem.demos.web.dto.vo.LoginVo;
import com.example.onlinereadingsystem.demos.web.service.LoginService;
import com.example.onlinereadingsystem.demos.web.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 登录页接口
 * @Author ljm
 * @Date 2024/10/8
 */
@RestController
@RequestMapping("/web/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * @auther ljm
     * @create 2024/12/30
     * @describe 登录接口
     */
    @PostMapping("/login")
    public Result<LoginVo> login(@RequestBody LoginParam param) {
        return loginService.login(param);
    }

    /**
     * @auther ljm
     * @create 2024/12/30
     * @describe 注册接口
     */
    @PostMapping("/register")
    public Result<Boolean> register(@RequestBody RegisterParam param) {
        return loginService.register(param);
    }

    /**
     * @auther ljm
     * @create 2024/12/30
     * @describe 生成验证码图片
     */
    @GetMapping("/randomImage/{key}")
    public Result<String> randomImage(@PathVariable String key) {
        return loginService.randomImage(key);
    }
}
